package models

import (
	"gorm.io/gorm"
	"time"
	"user_srv/basic/config"
)

type Cleaner struct {
	Id            uint           `gorm:"column:id;type:bigint(20) UNSIGNED;primaryKey;not null;" json:"id"`
	Nickname      string         `gorm:"column:nickname;type:varchar(30);comment:昵称;not null;" json:"nickname"`                                                          // 昵称
	Mobile        string         `gorm:"column:mobile;type:char(11);comment:手机号;not null;" json:"mobile"`                                                               // 手机号
	Sex           string         `gorm:"column:sex;type:varchar(20);comment:保洁性别;not null;" json:"sex"`                                                                // 保洁性别
	CleanerUrl    string         `gorm:"column:cleaner_url;type:varchar(255);comment:保洁头像;not null;" json:"cleaner_url"`                                               // 保洁头像
	CleanerType   uint           `gorm:"column:cleaner_type;type:tinyint(1) UNSIGNED;comment:保洁类型:1:保姆，2:临时工，3:金牌月嫂;not null;default:2;" json:"cleaner_type"` // 保洁类型:1:保姆，2:临时工，3:金牌月嫂
	CleanerStatus uint           `gorm:"column:cleaner_status;type:tinyint(1) UNSIGNED;comment:保洁状态:1:空闲，2:忙碌;not null;default:1;" json:"cleaner_status"`          // 保洁状态:1:空闲，2:忙碌
	CreatedAt     time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt     time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt     gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (c *Cleaner) TableName() string {
	return "cleaner"
}
func (c *Cleaner) UpdateStatus() error { //修改订单状态
	return config.DB.Model(&Cleaner{}).Where("id = ?", c.Id).Update("cleaner_status", c.CleanerStatus).Error
}
